

		**********************************************************
		** File: cleaning_CI_rights.do							**
		** Paper: Human Trafficking Indicators: A New Dataset	**
		** Author: Richard Frank								**
		** Date: July 11, 2021									**
		** Task: Cleaning CI Rights and CIRI					**
		**********************************************************
						
		clear all
		version 15.1
		set seed 1234
		set scheme lean1
		
		cd "~"
	

	** data were downloaded from: https://docs.google.com/document/d/1ZxuitRNKpTcEpwi_1p8u0IRnib7ggtKF9TQcf_jbmo0/edit?usp=sharing
	
	** Insheet CI data **
	import excel "ci_rights_data_project_dataset.xlsx", sheet("Sheet1") firstrow
	
	drop Y Z
	sort cow countryname year
	duplicates tag cow year, gen(dup)
	tab dup
	browse 	if dup==1
	drop if countryname=="Soviet Union" & year>1991
	drop if countryname=="Russia" & year <1992
	replace cow=339 if countryname=="Albania"
	replace cow=339 if countryname=="Albania "	
	drop dup
	duplicates tag cow year, gen(dup)
	browse 	if dup==2
	drop if countryname=="Yugoslavia" & year>1991
	drop if countryname=="Kosovo" & year<2009
	drop if countryname=="Montenegro" & year<2006
	drop if countryname=="Serbia and Montenegro" & year<1992
	drop if countryname=="Serbia and Montenegro" & year>2005
	drop if countryname=="Serbia and Montenegro" & year==2000	
	drop if countryname=="Serbia and Montenegro" & year==2001	
	drop if countryname=="Serbia and Montenegro" & year==2002	
	drop if countryname=="Yugoslavia, Federal Republic of" & year<2000
	drop if countryname=="Yugoslavia, Federal Republic of" & year>2002	
	drop if countryname=="Serbia" & year<2006
	replace cow=341 if countryname=="Montenegro"
	replace cow=341 if countryname=="Montenegro "	
	replace cow=347 if countryname=="Kosovo"	
	replace cow=347 if countryname=="Kosovo "
	replace cow=345 if countryname=="Serbia"
	replace cow=345 if countryname=="Serbia "	
	drop dup
	duplicates tag cow year, gen(dup)	
	tab dup
	browse 	if dup==1
	drop ciri polity unctry unreg unsubreg
	save ci_rights_data.dta, replace

	 
	** CLEANING DTA FILE **
	 
	use  "CIRIGHTS_Jul_21_2019.dta" , clear
	drop ciri   cow unctry unreg unsubreg ccode
	rename country Country
	run "cow.do"
	sort ccode
	tab Country if ccode==0
	sort ccode year
	duplicates report ccode year
	save  "CIRIGHTS 2019.dta"
